﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CashShop.Bussiness;

namespace CashShop
{
    public partial class Form1 : Form
    {
        private CashFacade cf = new CashFacade();
        private decimal totalPrice = 0M;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //读取xml文件，绑定下拉菜单
            cbxType.DataSource = cf.GetCashAccaptTypeList();
            cbxType.SelectedIndex = 0;
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            totalPrice = 0M;
            txbPrice.Text = "0.00";
            txbCount.Text = "0";
            lbList.Items.Clear();
            lblTotalPrice.Text = "0.00";
        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            var total = 0.00M;
            total = cf.GetTotalPrice(cbxType.SelectedItem.ToString(), Convert.ToDecimal(txbPrice.Text) * Convert.ToDecimal(txbCount.Text));
            totalPrice += total;
            lbList.Items.Add("单价：" + txbPrice.Text + ",数量：" + txbCount.Text + ",合计：" + total.ToString());
            lblTotalPrice.Text = totalPrice.ToString("C");
        }
    }
}
